home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / VIEWS.ZIP;1 / CVDZIP.EXE / CVFEATUR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-30  |  2.8 KB  |  135 lines

  1. /*
  2.     cvfeatur.cpp
  3.  
  4.     List of features window
  5.     
  6.     C++/Views 2.0 Demo
  7.     Copyright (c) 1992, by Liant Software Corp.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12. */
  13.  
  14. #include "cvfeatur.h"
  15. #include "cvdemovw.h"
  16. #include "editbox.h"
  17. #include "listbox.h"
  18. #include "messengr.h"
  19. #include "brush.h"
  20. #include "font.h"
  21. #include "tagstrm.h"
  22.  
  23. defineClass(FeatureView, VMdiView)
  24.  
  25. FeatureView::FeatureView()
  26. {
  27.     ;
  28. }
  29.  
  30. FeatureView::FeatureView(VFrame &f, DemoAppView *parent)
  31.     : VMdiView("FeatureIcon", f, (VWindow *) parent, StyleBorder | StyleTitle | StyleCloseBox | StyleSizable)
  32. {
  33.     mainWin = parent;
  34.  
  35.     setTitle("C++/Views Features");
  36.  
  37.     listFont = new VFont("Arial", 10);
  38.     listFont->bold(TRUE);
  39.     msgFont = new VFont("Arial", 10);
  40.  
  41.     /* create a list box */
  42.     listBox = new VListBox(VFrame(0.05F, 0.05F, 0.9F, 0.4F), this, StyleBorder);
  43.     listBox->uponClick(this, methodOf(FeatureView, singleClick),
  44.                              methodOf(FeatureView, doubleClick));
  45.  
  46.     listBox->setFont(listFont);
  47.  
  48.     /* read in list of features from the message file */
  49.     VTagStream    tagStrm;
  50.     VString        cmd;
  51.     VStream        flist(cvTextFile->getMessage("Features:List"));
  52.  
  53.     tagStrm.beginScan(&flist, NIL);
  54.     tagStrm.tags('(', ')');
  55.  
  56.     while(tagStrm.getTag(cmd)) {
  57.         listBox->appendString(cmd.gets());
  58.     }
  59.  
  60.     /* create an edit box */
  61.     msgBox = new VEditBox(VFrame(0.05F, 0.5F, 0.9F, 0.35F), this,
  62.                     StyleBorder | StyleVertical | StyleWordWrap | StyleReadOnly);
  63.  
  64.  
  65.     msgBox->setFont(msgFont);
  66.  
  67.     msgBox->putText(cvTextFile->getMessage("Features:Intro").gets());
  68.  
  69.     /* make sure the "About this Window" data is set up */
  70.     mainWin->setAboutNames("Feature:About", "cvfeatur.cpp");
  71. }
  72.  
  73. FeatureView::~FeatureView()
  74. {
  75.     /* destroy background brush (if present) */
  76.     delete getBackground();
  77.  
  78.     delete listFont;
  79.     delete msgFont;
  80. }
  81.  
  82. boolean FeatureView::free()
  83. {
  84.     delete this;
  85.     return(TRUE);
  86. }
  87.  
  88. boolean FeatureView::close()
  89. /*
  90.     The user has closed the window.
  91.     Notify the main window so that it can update the main menu bar
  92. */
  93. {
  94.     mainWin->featureView = 0;
  95.     mainWin->updateMenu();
  96.     return(FALSE);
  97. }
  98.  
  99. boolean FeatureView::singleClick(int index)
  100. /*
  101.     Mouse clicked on the list box
  102. */
  103. {
  104.     VString    idx("Features:");
  105.     VString *temp;
  106.  
  107.     temp = listBox->selectedString();
  108.     idx.concat(temp);
  109.     delete temp;
  110.  
  111.     msgBox->putText(cvTextFile->getMessage(idx.gets()).gets());
  112.     return(TRUE);
  113. }
  114.  
  115. boolean FeatureView::doubleClick(int index)
  116. /*
  117.     Mouse double-clicked on the list box
  118. */
  119. {
  120.     return(TRUE);
  121. }
  122.  
  123. boolean FeatureView::givenFocus()
  124. /*
  125.     Our window has just been given input focus
  126. */
  127. {
  128.     /* set the data for the About this Window dialog */
  129.     mainWin->setAboutNames("Feature:About", "cvfeatur.cpp");
  130.  
  131.     /* carry on with default window behavior, return FALSE */
  132.     return(FALSE);
  133. }
  134.  
  135.